﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iOak.Business.Campaigns;
using iOak.Domain.Campaigns;

namespace iOak.Web.Administration
{
    public partial class ApplicationCandidateList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) 
            {
                if (!String.IsNullOrWhiteSpace(this.Request.QueryString["applicationId"]))
                {
                    Guid applicationId = Guid.Parse(this.Request.QueryString["applicationId"]);
                    IniData(applicationId);
                }
            }
        }

        /// <summary>
        /// 数据初始化
        /// </summary>
        /// <param name="applicationId"></param>
        private void IniData(Guid applicationId) 
        {
            ApplicationService applicationService = new ApplicationService();
            ApplicationBase applicationBase = applicationService.Retrieve(applicationId);
            if (applicationBase != null) 
            {
                candidateList.BindData(applicationId.ToString());
                CampaignService campaignService = new CampaignService();
                Campaign campaign = campaignService.Retrieve(applicationBase.CampaignId);
                if(campaign != null)
                {
                    lblSubject.Text = campaign.Subject;
                    lblDescription.Text = campaign.Description;
                    lblStartDate.Text = campaign.StartDate.ToString("yyyy-MM-dd");
                }
            }
        }
    }
}